home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / strg61b.zip / STRG61B-.PAS < prev    next >
Pascal/Delphi Source File  |  1991-06-17  |  9KB  |  237 lines

  1. { ========================================================================== }
  2. { Strg61b-.pas - String Processing Routines - Interface   ver 6.1b, 06-17-91 }
  3. {                                                                            }
  4. { (Partial source code)                                                      }
  5. { These routines process strings, characters, and all types of numbers.      }
  6. { Several combinations of operations have been provided that are extremely   }
  7. { fast for case, classification, comparison, conversions, copy, count,       }
  8. { delete, format, justification, membership, parse, replace, search, sort,   }
  9. { tabbing, ASCIIZ, many with match/ignore case and many more - 111 routines. }
  10. {  Copyright (C) 1989-1991 James H. LeMay                                    }
  11. { ========================================================================== }
  12.  
  13. { For IEEE reals, set $N+.  For runtime selection of 80x87 and software,     }
  14. { also use $E+.  (Note that use of $E+ will link Turbo's 12k emulator lib if }
  15. { a procedure is called.)  These directives must also be reflected in the    }
  16. { main program as well.  This is so you can test everything in the unit.     }
  17.  
  18. {$A-,D-,E+,I-,L-,N+,R-,S-,V-}   { For IEEE }
  19.  
  20. { If you have the source code and have SYS60.TPU or later, set the following }
  21. { conditional define by deleting the space in front of the '$'.  It will     }
  22. { then ignore the substitute routines for Delete, Copy, and Pos which are    }
  23. { duplicates. }
  24.  
  25. { $Define SysTpu      }
  26. {^ delete this space. }
  27.  
  28.  
  29. UNIT Strg;
  30.  
  31. INTERFACE
  32.  
  33. var
  34.   AscSrcPtr:          pointer;    { For StrAsc  }
  35.   AscDestPtr:         pointer;    { For AscStr  }
  36.   LnSrcPtr:           pointer;    { For StrLn   }
  37.   LnDestPtr:          pointer;    { For LnStr   }
  38.   CmpIndex1:          integer;    { For StrCmp  }
  39.   CmpIndex2:          integer;    { For StrCmp  }
  40.   ReplIndex,ReplToDo: byte;       { For StrRepl }
  41.   ReplOverFlow:       boolean;    { For StrRepl }
  42.  
  43.  
  44. { -- String Operations (5) -- }
  45.  
  46. procedure StrUpr  (VAR S: string);
  47. procedure StrLwr  (VAR S: string);
  48. procedure StrRev  (VAR S: string);
  49. procedure StrSort (VAR S: string);
  50. procedure StrRoll (VAR S: string; Count: integer);
  51.  
  52.  
  53. { -- String Insert/Delete (8) -- }
  54.  
  55. procedure StrIns  (VAR Dest: string; S: string; DestIndex,MaxLen: byte);
  56. procedure ChrPadC (VAR S: string; Fill: char; Field: byte);
  57. procedure ChrPadL (VAR S: string; Fill: char; Field: byte);
  58. procedure ChrPadR (VAR S: string; Fill: char; Field: byte);
  59. procedure ChrDel  (VAR S: string; Find: char);
  60. procedure ChrDelL (VAR S: string; Find: char);
  61. procedure ChrDelR (VAR S: string; Find: char);
  62. procedure StrCut  (VAR S: string; MaxLen: byte);
  63.  
  64.  
  65. { -- String Placement (7) -- }
  66.  
  67. procedure StrCat  (VAR Dest: string; S: string; MaxLen: byte);
  68. procedure StrCatX (VAR Dest: string; S: string; indeX,Count,MaxLen: byte);
  69. procedure StrCopy (VAR Dest: string; S: string; Index,Count: byte);
  70. procedure StrOvr  (VAR Dest: string; S: string; DestIndex: byte);
  71. procedure StrMove (VAR Dest: string; S: string);
  72. procedure StrPoke (VAR Dest; S: string);
  73. procedure StrPeek (VAR Dest: string; VAR Source; Count: byte);
  74.  
  75.  
  76. { -- String Pattern (3) -- }
  77.  
  78. procedure StrFill (VAR S: string; Fill: string; Count,MaxLen: byte);
  79. procedure ChrFill (VAR S: string; Fill: char;   Count: byte);
  80. procedure StrEnum (VAR S: string; First,Last: char);
  81.  
  82.  
  83. { -- String Position (12) -- }
  84.  
  85. function  StrPosL  (S,Find: string; Nth: byte):          byte;
  86. function  StrPosLI (S,Find: string; Nth: byte):          byte;
  87. function  StrPosR  (S,Find: string; Nth: byte):          byte;
  88. function  StrPosRI (S,Find: string; Nth: byte):          byte;
  89. function  StrPosX  (S,Find: string; indeX: byte):        byte;
  90. function  StrPosXI (S,Find: string; indeX: byte):        byte;
  91.  
  92. function  ChrPosL  (S: string; Find: char; Nth: byte):   byte;
  93. function  ChrPosLI (S: string; Find: char; Nth: byte):   byte;
  94. function  ChrPosR  (S: string; Find: char; Nth: byte):   byte;
  95. function  ChrPosRI (S: string; Find: char; Nth: byte):   byte;
  96. function  ChrPosX  (S: string; Find: char; indeX: byte): byte;
  97. function  ChrPosXI (S: string; Find: char; indeX: byte): byte;
  98.  
  99.  
  100. { -- String Count (4) -- }
  101.  
  102. function  StrQty   (S,Find: string):        byte;
  103. function  StrQtyI  (S,Find: string):        byte;
  104. function  ChrQty   (S: string; Find: char): byte;
  105. function  ChrQtyI  (S: string; Find: char): byte;
  106.  
  107.  
  108. { -- String Comparison (2) -- }
  109.  
  110. function  StrCmp   (S1,S2: string; Index1,Index2,MaxLen: byte): shortint;
  111. function  StrCmpI  (S1,S2: string; Index1,Index2,MaxLen: byte): shortint;
  112.  
  113.  
  114. { -- String Find and Replace Operations (4) -- }
  115.  
  116. procedure ChrRepl  (VAR S: string; Find,Repl: char; Index,Qty: byte);
  117. procedure ChrReplI (VAR S: string; Find,Repl: char; Index,Qty: byte);
  118. procedure StrRepl  (VAR S: string; Find,Repl: string; Index,Qty,MaxLen: byte);
  119. procedure StrReplI (VAR S: string; Find,Repl: string; Index,Qty,MaxLen: byte);
  120.  
  121.  
  122. { -- String Member/Non-member (3) -- }
  123.  
  124. function  StrBrk   (S,Breaks:  string; Index: byte): byte;
  125. function  StrSpn   (S,Members: string; Index: byte): byte;
  126. procedure StrMemb  (VAR Dest: string; S: string);
  127.  
  128.  
  129. { -- String Parsing routines (11) -- }
  130.  
  131. function  WrdQty   (S: string):              byte;
  132. function  WrdPosL  (S: string; Nth: byte):   byte;
  133. function  WrdPosR  (S: string; Nth: byte):   byte;
  134. function  WrdPosLX (S: string; indeX: byte): byte;
  135. function  WrdPosRX (S: string; indeX: byte): byte;
  136. procedure WrdL     (VAR Dest: string; S: string; Nth: byte);
  137. procedure WrdR     (VAR Dest: string; S: string; Nth: byte);
  138. procedure WrdLX    (VAR Dest: string; S: string; indeX: byte);
  139. procedure WrdRX    (VAR Dest: string; S: string; indeX: byte);
  140. procedure WrdToken (VAR Dest: string; S,Delims: string; VAR Index: byte);
  141. procedure WrdParse (VAR Dest: string; S,Delims: string; VAR Index: byte);
  142.  
  143.  
  144. { -- String Conversions (10) -- }
  145.  
  146. function  StrHex (Num: longint; Field: byte):    string;
  147. function  StrBin (Num: longint; Field: byte):    string;
  148. function  ValBin (S: string; VAR Code: integer): longint;
  149. function  ValHex (S: string; VAR Code: integer): longint;
  150.  
  151. procedure StrDeTab (VAR Dest: string; S: string; TabSpaces: byte);
  152. procedure StrReTab (VAR Dest: string; S: string; TabSpaces: byte);
  153.  
  154. procedure AscStr (VAR AscDest; S: string);
  155. procedure LnStr  (VAR LnDest;  S: string);
  156. procedure StrAsc (VAR Dest: string; VAR AscSrc; MaxLen: byte);
  157. procedure StrLn  (VAR Dest: string; VAR LnSrc;  MaxLen: byte);
  158.  
  159.  
  160. { -- Automatic and FASTER replacement for Pascal standard routines (3) -- }
  161.  
  162. {$ifndef SysTpu }
  163. procedure Delete (VAR S: string; Index,Count: integer);
  164. function  Copy   (    S: string; Index,Count: integer): string;
  165. function  Pos    (Find,S: string): byte;
  166. {$endif }
  167.  
  168.  
  169. { -- String Justification (3) -- }
  170.  
  171. function  StrJL  (S: string; Field: byte): string;
  172. function  StrJC  (S: string; Field: byte): string;
  173. function  StrJR  (S: string; Field: byte): string;
  174.  
  175.  
  176. { ** Function forms of the standard STR procedure ** }
  177. { -- String Formatting (17) -- }
  178.  
  179. function  StrL   (L: longint):                       string;
  180. function  StrLF  (L: longint; Field: integer):       string;
  181. function  StrR   (R: real):                          string;
  182. function  StrRF  (R: real; Field: integer):          string;
  183. function  StrRFD (R: real; Field,Decimals: integer): string;
  184.  
  185.  
  186. { -- IEEE reals -- }
  187.  
  188. {$ifopt N+ }
  189. function  StrS   (S: single):                            string;
  190. function  StrSF  (S: single; Field: integer):            string;
  191. function  StrSFD (S: single; Field,Decimals: integer):   string;
  192. function  StrD   (D: double):                            string;
  193. function  StrDF  (D: double; Field: integer):            string;
  194. function  StrDFD (D: double; Field,Decimals: integer):   string;
  195. function  StrE   (E: extended):                          string;
  196. function  StrEF  (E: extended; Field: integer):          string;
  197. function  StrEFD (E: extended; Field,Decimals: integer): string;
  198. function  StrC   (C: comp):                              string;
  199. function  StrCF  (C: comp; Field: integer):              string;
  200. function  StrCFD (C: comp; Field,Decimals: integer):     string;
  201. {$endif N+ }
  202.  
  203.  
  204. { -- Character case functions. (2) -- }
  205.  
  206. function  LoCase (C: char): char;
  207. function  UpCase (C: char): char;
  208.  
  209.  
  210. { -- Character classification functions. (17) -- }
  211.  
  212. function  IsAlNum  (C: char): boolean;
  213. function  IsAlpha  (C: char): boolean;
  214. function  IsASCII  (C: char): boolean;
  215. function  IsCntrl  (C: char): boolean;
  216. function  IsDigit  (C: char): boolean;
  217. function  IsDos    (C: char): boolean;
  218. function  IsFile   (C: char): boolean;
  219. function  IsGraph  (C: char): boolean;
  220. function  IsLower  (C: char): boolean;
  221. function  IsPath   (C: char): boolean;
  222. function  IsPrint  (C: char): boolean;
  223. function  IsPunct  (C: char): boolean;
  224. function  IsReal   (C: char): boolean;
  225. function  IsSigned (C: char): boolean;
  226. function  IsSpace  (C: char): boolean;
  227. function  IsUpper  (C: char): boolean;
  228. function  IsXDigit (C: char): boolean;
  229.  
  230.  
  231. { 90 unique / 111 total routines }
  232.  
  233.  
  234. IMPLEMENTATION
  235.  {...}
  236. END.
  237.